﻿using DayuCode.Designer.Entity;
using DayuCode.Designer.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DayuCode.Designer.Service
{
    public class DatasetDefHandler
	{
		private static string getBaseUrl(string methodName)
		{
			return AppInstance.ApiServer + "api/base/dayucode_datasetDefHandler/" + methodName;
		}

		public static void deleteDatasetDef(long id)
		{
			QHttpClient.Execute(getBaseUrl("deleteDatasetDef"), new { id = id });
		}

		public static DatasetDef getDatasetDef(long id)
		{
			DatasetDef obj = QHttpClient.Post<DatasetDef>(getBaseUrl("getDatasetDef"), new { id = id });
			return obj;
		}

		public static DatasetDef saveDatasetDef(DatasetDef item, string tableName, string className)
		{
			DatasetDef obj = QHttpClient.Post<DatasetDef>(getBaseUrl("saveDatasetDef"), new { item = item, tableName = tableName, className = className });
			return obj;
		}

		public static IList<DatasetDef> getDatasetDefs(long funcId)
		{
			IList<DatasetDef> obj = QHttpClient.Post<List<DatasetDef>>(getBaseUrl("getDatasetDefs"), new { funcId = funcId });
			return obj;
		}
	}
}
